package com.netease.nim.demo.contact.model;

import android.text.TextUtils;

public class Buddy extends AbsContact {

    private String account;

    private String name;

    private int icon;

    public Buddy() {
        this.icon = 0;
    }

    public Buddy(String account, String name, int icon) {
        this.account = account;
        this.name = name;
        this.icon = icon;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null) {
            return false;
        }

        if (o == this) {
            return true;
        }

        Buddy other = (Buddy) o;
        if (this.account.equals(other.getAccount()) && this.name.equals(other.getName()) &&
                this.icon == other.getIcon()) {
            return true;
        }

        return false;
    }

    @Override
    public String getContactId() {
        return getAccount();
    }

    @Override
    public int getContactType() {
        return IContact.Type.Buddy;
    }

    @Override
    public String getDisplayname() {
        return TextUtils.isEmpty(name) ? account : name;
    }
}
